﻿#ifndef QSLOGTABLEMODEL_H
#define QSLOGTABLEMODEL_H

#pragma once

#include "qslog/QsLog.h"
#include "qslog/QsLogDest.h"
#include <QDir>
#include <QAbstractTableModel>
#include <QStringList>

class QsLogTableModel : public QAbstractTableModel
{
    Q_OBJECT

public:
    explicit QsLogTableModel(QObject *parent = 0);

    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    void setDisLevel(int l);
    void setHistoryData(QStringList& his);

    void clearDisLevel(int level);

    int getDisLevel()
    {
        return disLevel;
    }

public slots:
    void logSlot(const QString &message, int level);
private:
    QStringList logMessages;
    QStringList infoMessages;
    QStringList warnMessages;
    QStringList fatalMessages;
    int maxStoreMessages;
    int maxDisMessages;

    int disLevel;
    int lastLevel;
};

#endif // QSLOGTABLEMODEL_H
